package com.testpro.DesignPattern.FactoryPattern;

import com.sun.istack.internal.NotNull;

public class CarFactory  extends AbstractCarFactory
{


    @Override
    public Car getnewCar() {
        return new newCar();
    }

    @Override
    public Car getOldCar() {
        return new oldCar();
    }

    @Override
    public Car defultInstance() {
        return new newCar();
    }

    @Override
    public Car getInstanceForString(@NotNull String InstanceName) {

        if (InstanceName.equals("newCar"))
        {
            return this.getnewCar();
        }else if (InstanceName.equals("oldCar"))
        {
            return this.getOldCar();
        }
        else {
            return this.defultInstance();
        }
    }
}
